#include <leaf/sensor.h>
#include <util/delay.h>
#include <leaf/base.h>
/*
 * 10us采样一次，采样若干次，若这几次都为所需，则判断成功, 之所以时间控制器要用传入参数，是为了维持可重入性
 */
/*所需的是低电平*/
Bool judge_sensor_low(volatile uint8_t *p, uint8_t b, uint8_t jt ){
	uint8_t i;
	Bool res = True;
	for(i = 0; i < jt; ++i){
		if(bit_is_set(*p, b)){
			res = False;
			break;
		}
		_delay_us( 10 );
	}
	return res;
}

/*所需的是高电平*/
Bool judge_sensor_high(volatile uint8_t *p, uint8_t b, uint8_t jt ){
	uint8_t i;
	Bool res = True;
	for(i = 0; i < jt; ++i){
		if(bit_is_clear(*p, b)){
			res = False;
			break;
		}
		_delay_us( 10 );
	}
	return res;
}

